#pragma once

#include "mzfc.h"

#include <vector>
#include <string>
#include "Helper.h"
#include "common.h"

#define EDIT_MIN_FONT							16
#define EDIT_MAX_FONT							32
#define EDIT_FONT_CHAGE_STEP			4

typedef struct  
{
	CRect rcLine;
	std::wstring strLine;
	std::vector<CRect> rcChars;
}stEditLineStrInfo;

class MZFC_API CEditString
{
public:
	CEditString(void);
	~CEditString(void);
private:
	std::wstring m_strEdit;
	int m_nCurPos;
	std::vector<stEditLineStrInfo>  m_vStrLineCaretPos; 
	int m_nLineHeight;
	POINT m_curCaretPoint;
	bool isWordChar(TCHAR c);	

public:	
	BOOL getMultiLineTextExtent(HDC hdc, int nMaxExten);
	BOOL getParagraphTextExtent(HDC hdc, const std::wstring & str, int nMaxExten);
	int getLineNum(){return m_vStrLineCaretPos.size();}
	stEditLineStrInfo& getLineStrInfo(int pos){return m_vStrLineCaretPos[pos];}
	BOOL getSingleLineTextExtent(HDC hdc);
	int addMultiLineChar(int pos, TCHAR c, HDC hdc, int screenWidth);
	int removeMultiLineChar(int pos, HDC hdc, int screenWidth);
	int addSingleLineChar(int pos, TCHAR c, HDC hdc, int screenWidth, int& fontSize);
	int removeSingleLineChar(int pos, HDC hdc, int screenWidth, int& fontSize);
	int getRect(int pos,CRect * prc);
	int getPos(POINT pt);
	int getCurPos(){return m_nCurPos;}
	void setCurPos(int pos){m_nCurPos = pos;}
	void setLineHeight(int h){m_nLineHeight = h;}
	bool isSingleLineEditSpaceEnough(HDC hdc, int editWidth);
	int getSingleLineStrExtent(HDC hdc);
	std::wstring& getAllStr(){return m_strEdit;}
	void setAllStr(std::wstring InStr){m_strEdit = InStr;}
	int initSingleLineStr(HDC hdc, std::wstring str);
	int initMultiLineStr(HDC hdc, std::wstring str, int editWidth);
	void addImageChar(stImageInfo imgf);
	void addAffixInfo(stAffixInfo affix);
	BOOL FindPic(int LineNo,stImageInfo **img);
	int getStrHeight();
	bool RemoveImage( HDC hdc, int screenWidth);
	bool RemoveAffix(HDC hdc, int screenWidth);
	bool RemoveAllAffix();
	std::vector<stImageInfo>  m_ImageList; 
	std::vector<stAffixInfo>  m_AffixList; 
};
